import { type SiriusVulnerability } from "~/server/api/routers/vulnerability";

// Type for aggregated vulnerability data across hosts
export interface AggregatedVulnerability {
  vid: string; // Unique vulnerability ID
  cve?: string; // CVE identifier (if available)
  title: string; // Vulnerability title
  description: string; // Description
  severity: string; // Severity level (critical, high, medium, low, informational)
  hostCount: number; // Number of hosts affected
  hosts: string[]; // List of host IPs affected
  exploitable?: boolean; // Whether this is known to be exploitable
  riskScore?: number; // Calculated risk score
}

// Response type for the getAllVulnerabilities query
export interface VulnerabilityAggregationResponse {
  vulnerabilities: AggregatedVulnerability[];
  counts: {
    total: number;
    critical: number;
    high: number;
    medium: number;
    low: number;
    informational: number;
  };
  hostTotals: {
    [hostIp: string]: HostVulnerabilityCounts;
  };
}

// Type for individual host vulnerability severity counts
export interface HostVulnerabilityCounts {
  critical: number;
  high: number;
  medium: number;
  low: number;
  informational: number;
  total: number;
}

// Mapping from host IP to its vulnerability counts
export type HostVulnerabilityMap = Map<string, HostVulnerabilityCounts>;

// Type augmentation for TanStack Table's table.options.meta
declare module "@tanstack/react-table" {
  interface TableMeta<TData> {
    hostVulnMap?: Record<string, HostVulnerabilityCounts>;
  }
}
